package com.communal.web.form.tarif;

import net.sf.ezmorph.bean.MorphDynaBean;
import net.sf.json.JSONObject;

import com.communal.model.tarif.TarifRent;
import com.communal.web.form.BaseForm;

/**
 * 
 * @author Created by andrey.kuznetsov <br>
 * @author Last modified by $Author$ <br>
 * @author Last modified on $Date$ at revision $Revision$ <br>
 */
public class TarifRentForm extends BaseForm{

	private final String TARIF_NAME = "tarifName";
	private final String AREA = "area";
	private final String PEOPLE_AMOUNT = "peopleAmount";
	private final String SUMMA = "summa";
	
	private String tarifName;
	private Short area;
	private Short peopleAmount;
	private Double summa;
	
	/**
	 * Constructor from JSON data for {@link TarifRentForm} <br>
	 * @param p_data - JSON data
	 */
	public TarifRentForm(Object p_data) {
		super( p_data, true );
		JSONObject jsonObject = JSONObject.fromObject(p_data);
		MorphDynaBean bean = (MorphDynaBean) JSONObject.toBean(jsonObject);
		tarifName = bean.get(TARIF_NAME).toString();
		area = Short.parseShort(bean.get(AREA).toString());
		peopleAmount = Short.parseShort(bean.get(PEOPLE_AMOUNT).toString());
		summa = Double.parseDouble(bean.get(SUMMA).toString());
	}
	
	/**
	 * Constructor from rent tarif model <br>
	 * @param p_tarif - rent tarif model; {@link TarifRent}
	 */
	public TarifRentForm(TarifRent p_tarif) {
		super( p_tarif );
		tarifName = p_tarif.getTarifName();
		area = p_tarif.getArea();
		peopleAmount = p_tarif.getPeopleAmount();
		summa = p_tarif.getSumma();
	}

	/**
	 * Returns name of tarif <br>
	 * @return {@link String};
	 */
	public String getTarifName() {
		return tarifName;
	}

	/**
	 * Sets name of tarif <br>
	 * @param p_tarifName - {@link String};
	 */
	public void setTarifName(String p_tarifName) {
		tarifName = p_tarifName;
	}

	/**
	 * Returns area of location <br>
	 * @return {@link Short};
	 */
	public Short getArea() {
		return area;
	}

	/**
	 * Sets area of location <br>
	 * @param p_area - {@link Short};
	 */
	public void setArea(Short p_area) {
		area = p_area;
	}

	/**
	 * Returns amount of people registerd in location <br>
	 * @return {@link Short};
	 */
	public Short getPeopleAmount() {
		return peopleAmount;
	}

	/**
	 * Sets amount of people registered in location <br>
	 * @param p_peopleAmount - {@link Short};
	 */
	public void setPeopleAmount(Short p_peopleAmount) {
		peopleAmount = p_peopleAmount;
	}

	/**
	 * Returns summa of payment <br>
	 * @return {@link Double};
	 */
	public Double getSumma() {
		return summa;
	}

	/**
	 * Sets summa for payment <br>
	 * @param p_summa - {@link Double};
	 */
	public void setSumma(Double p_summa) {
		summa = p_summa;
	}
	
	
}
